package xyz.xtt.asset.service;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.baomidou.mybatisplus.extension.service.IService;

import xyz.xtt.asset.api.enums.AssetTypeEnum;
import xyz.xtt.asset.api.enums.SellPatternEnum;
import xyz.xtt.asset.client.response.AssetAllInfoResponse;
import xyz.xtt.asset.client.response.AssetDetailInfo;
import xyz.xtt.asset.client.response.AssetInfoResponse;
import xyz.xtt.asset.client.response.AssetVo;
import xyz.xtt.asset.client.response.NftListVo;
import xyz.xtt.asset.client.response.SecondAssetListVo;
import xyz.xtt.asset.client.response.TblAssetExpandDto;
import xyz.xtt.asset.entity.TblAsset;
import xyz.xtt.asset.enums.SortOrder;
import xyz.xtt.asset.enums.SortType;
import xyz.xtt.asset.request.CreateRequest;
import xyz.xtt.asset.request.UpdateAssertRequest;
import xyz.xtt.asset.response.QueryAssetInfoResponse;
import xyz.xtt.asset.vo.AssetBaseInfo;
import xyz.xtt.asset.vo.MyAssetsResponse;
import xyz.xtt.asset.vo.MyAssetsVo;
import xyz.xtt.asset.vo.PaySyncMessageVo;

/**
 * <p>
 * 资产基础信息表 服务类
 * </p>
 *
 * @author author
 * @since 2024-10-17
 */
public interface ITblAssetService extends IService<TblAsset> {
	/**
	 * 资产上链接口
	 * 
	 * @param createRequest
	 * @return
	 */
//	Boolean create(CreateRequest createRequest);

	/**
	 * 批量开通地皮
	 * 
	 * @param createRequestList
	 * @return
	 */
	Boolean createBatch(List<CreateRequest> createRequestList);

	/**
	 * 查询详情
	 * 
	 * @param busId
	 * @return
	 */
	TblAsset info(String busId);

	/**
	 * 根据bizId从缓存中查询资产信息
	 * 
	 * @param busId
	 * @return
	 */
	TblAsset infoWithBizIdByCache(String busId);

	/**
	 * @param id
	 * @return
	 */
	TblAsset infoWithIdByCache(Long id);

	/**
	 * 匹量查询
	 * 
	 * @param busIds
	 * @return
	 */
	List<TblAsset> info(List<String> busIds);

	/**
	 * 更新
	 * 
	 * @param updateAssertRequest
	 * @return
	 */
	Boolean update(UpdateAssertRequest updateAssertRequest);

	/**
	 * 根据资产编号查询详情
	 * 
	 * @param assetsCode
	 * @return
	 */
	QueryAssetInfoResponse queryInfo(String assetsCode);

	/**
	 * * 支付结果同步
	 * 
	 * @param paySyncMessageVo
	 * @return
	 */
	Boolean payResultSync(PaySyncMessageVo paySyncMessageVo);

	/**
	 * 我的资产
	 * 
	 * @param uid
	 * @return
	 */
	MyAssetsVo getMyAssets(String uid);

	/**
	 * 我的资详情
	 * 
	 * @param uid
	 * @return
	 */
	List<AssetVo> queryAsset(String uid);

	/**
	 * 消息数据解析
	 * 
	 * @param list
	 * @return
	 */
//	List<SyncResponseMsg> parseBatch(List<CreateRequest> list);

	/**
	 * 解析单个消息
	 * 
	 * @param createRequest
	 * @return
	 */
//	AssetSynVo parse(CreateRequest createRequest);

	/**
	 * 查询指定的分类
	 * 
	 * @param uid
	 * @param type
	 * @return
	 */
	List<AssetVo> queryAssetType(String uid, AssetTypeEnum type);

	/**
	 * 更新资产的拥有人
	 * 
	 * 相当于转移操作
	 * 
	 * @param from
	 * @param to
	 * @param assetId
	 * @return
	 */
	Boolean updateOwner(String from, String to, Long assetId);

	/**
	 * 查询商品id对应资产信息
	 * 
	 * @param assetGoodsId 商品id
	 * @return 资产
	 */
	TblAsset assetInfoWithGoodsId(String assetGoodsId);

	/**
	 * 关联资产的数量 用于计算下一个数量
	 * 
	 * @param parentId
	 * @return
	 */
	Long childCount(Long parentId);

	/**
	 * 下一个编号 带假数
	 * 
	 * @param parentId
	 * @return
	 */
	Long nextSeqNoFake(Long parentId);

	/**
	 * @param parentId
	 * @return
	 */
	Long nextSeqNo(Long parentId);

	/**
	 * @param parentId
	 * @param isOpenFake
	 * @return
	 */
	Long nextSeqNo(Long parentId, Boolean isOpenFake);

	/**
	 * 更新编号
	 * 
	 * @param nextSeqNo
	 * @return
	 */
	Long updateSeqNo(Long parentId, Long incrementVal);

	/**
	 * 玫瑰花真实销量
	 * 
	 * @param parentId
	 * @return
	 */
	Long roseSellStatis(Long parentId, boolean third);

	/**
	 * @param busId
	 * @param secondType
	 * @param ownerUid
	 * @return
	 */
	TblAsset infoByParentIdAndSecondType(String busId, Integer secondType, String ownerUid);

	/**
	 * 增加数量
	 * 
	 * @param busId
	 * @param secondType
	 * @param ownerUid
	 * @return
	 */
	Boolean assetAmountIncr(Long id, Integer secondType, String ownerUid);

	/**
	 * 热度计算器
	 * 
	 * @param goodsId
	 * @param popularity
	 * @return
	 */
	Boolean assetPopularity(String goodsId, BigDecimal popularity);

	/**
	 * 首页查询数据列表
	 *
	 * @param uid
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
	List<NftListVo> getIndexList(Long uid, Integer currentPage, Integer pageSize, SortType sortType, SortOrder sortOrder);

	Map<Long, Long> getSeqNo();

	/**
	 * 根据goodsId查详情
	 * 
	 * @param goodsId
	 * @return
	 */
	AssetBaseInfo infoGoodsId(String goodsId);

	/**
	 * 查资产的所有详情信息 根据assetId
	 * 
	 * @param assetId
	 * @return
	 */
	AssetBaseInfo infoAssetId(Long assetId);

	Map<String, AssetVo> getAssetListByIds(Set<Long> hashSet);

	/**
	 * 用户资产上架数量
	 * 
	 * @param uid
	 * @return
	 */
	Long queryPutOn(String uid);

	MyAssetsResponse getMyAssets(String uid, Integer currPage, Integer type);

	List<AssetVo> queryAssetType(Integer currPage, String uid, AssetTypeEnum type);

	TblAssetExpandDto getAssetExpand(Long assetId);

	/**
	 * @param id
	 * @param price
	 * @param guidePrice
	 * @param oldSellPattern
	 * @param newSellPattern
	 * @return
	 */
	boolean updateAsset(Long id, BigDecimal price, BigDecimal guidePrice, SellPatternEnum oldSellPattern, SellPatternEnum newSellPattern);

	/**
	 * 更新资产状态
	 * 
	 * @param assetId
	 * @param oldSellPattern
	 * @param newSellPattern
	 * @return
	 */
	boolean updateSellPattern(Long assetId, SellPatternEnum oldSellPattern, SellPatternEnum newSellPattern);

	/**
	 * 匹量根据goodsId获取资产详情
	 * 
	 * @param goodsIds
	 * @return
	 */
	Map<String, AssetAllInfoResponse> batchInfoGoodsIds(Collection<String> goodsIds);

	/**
	 * 匹量根据assetId获取资产详情
	 * 
	 * @param assetIds
	 * @return
	 */
	Map<Long, AssetAllInfoResponse> batchInfoAssetId(Collection<Long> assetIds);

	/**
	 * 根据goodsId获取资产详情
	 * 
	 * @param goodsId
	 * @return
	 */
	AssetAllInfoResponse infoWithGoodsId(String goodsId);

	/**
	 * 根据assetId获取资产详情
	 * 
	 * @param assetId
	 * @return
	 */
	AssetAllInfoResponse infoWithAssetId(Long assetId);

	AssetInfoResponse queryAssetInfoResponseInfoWithAssetId(Long assetId);

	AssetInfoResponse queryAssetInfoResponseInfoWithGoodsId(String goodsId);

	List<AssetInfoResponse> queryBatchAssetInfoResponseWithGoodsId(Collection<String> goodsId);

	List<AssetInfoResponse> queryBatchAssetInfoResponseWithAssetId(Collection<Long> assetIds);

	/**
	 * 点赞和取消点赞
	 * 
	 * @param goodsId
	 * @param targetValue
	 * @return
	 */
	Boolean adjustPopularityRate(String goodsId, int targetValue);

	/**
	 * 根据父id查询资产
	 * 
	 * @param parentId
	 * @return
	 */
	List<TblAsset> getByParentIdCacheable(Long parentId);

	/**
	 * 非业务代码，是内部的Asset脚本处理代码
	 *
	 * @param sortedTblAssets
	 * @param batchSize
	 */
	void batchDisposeScriptRestList(List<TblAsset> sortedTblAssets, Integer batchSize);

	/**
	 * 获取盲盒下资产列表
	 * 
	 * @param asset
	 * @return
	 */
	List<SecondAssetListVo> getBoxSecondListCache(TblAsset asset);

	List<SecondAssetListVo> getBoxSecondList(TblAsset asset);

	AssetDetailInfo detailInfo(String uid, String goodsId, Long accountId);

	List<SecondAssetListVo> getBoxSecondListCache(Long assetId, String goodsId);
}
